#include <REGX52.H>
#include "Delay.h"

/**
  * @brief   获取是否按下按键
  * @details 
  * @param   
  * @retval  1~4分别代表K1~K4，0表示无按下任何按钮
  */
unsigned char Key() {
	unsigned char pressKey = 0;
	
	if (P3_1 == 0) {
		Delay(10);
		while (P3_1 == 0);
		Delay(10);
		pressKey = 1;
	}
	if (P3_0 == 0) {
		Delay(10);
		while (P3_0 == 0);
		Delay(10);
		pressKey = 2;
	}
	if (P3_2 == 0) {
		Delay(10);
		while (P3_2 == 0);
		Delay(10);
		pressKey = 3;
	}
	if (P3_3 == 0) {
		Delay(10);
		while (P3_3 == 0);
		Delay(10);
		pressKey = 4;
	}
	
	return pressKey;
}